package member.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import member.domain.MemberLevel;
import member.service.MemberLevelService;
import com.feign.utils.GetUtils;
import com.feign.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.Arrays;
import java.util.Map;

/**
 * 会员等级(MemberLevel)表控制层
 *
 * @author panghu
 * @since 2023-03-04 21:10:51
 */
@RestController
@RequestMapping("/member/memberLevel")
public class MemberLevelController {

    @Autowired
    private MemberLevelService memberLevelService;

    @GetMapping("list")
    public R getBrandList(HttpServletRequest request) {
        Map<String, Object> params = GetUtils.getParamsWithMapByRequest(request);
        Page<MemberLevel> memberLevelPage = memberLevelService.queryPage(params);
        return R.ok().put("data", memberLevelPage);
    }

    @GetMapping("info/{id}")
    public R getMemberLevelInfo(@PathVariable Long id) {
        MemberLevel memberLevel = memberLevelService.getById(id);
        return R.ok().put("data", memberLevel);
    }

    @PostMapping("save")
    public R save(@RequestBody MemberLevel memberLevel) {
        memberLevelService.save(memberLevel);
        return R.ok();
    }

    @PutMapping("update")
    public R update(@RequestBody MemberLevel memberLevel) {
        memberLevelService.updateById(memberLevel);
        return R.ok();
    }

    @PostMapping("remove")
    public R remove(@RequestBody Long[] ids) {
        memberLevelService.removeBatchByIds(Arrays.asList(ids));
        return R.ok();
    }
}

